home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / Number.java < prev    next >
Text File  |  1998-09-22  |  3KB  |  106 lines

  1. /*
  2.  * @(#)Number.java    1.21 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.lang;
  16.  
  17. /**
  18.  * The abstract class <code>Number</code> is the superclass of 
  19.  * classes <code>Byte</code>, <code>Double</code>, <code>Float</code>,
  20.  * <code>Integer</code>, <code>Long</code>, and <code>Short</code>.
  21.  * <p>
  22.  * Subclasses of <code>Number</code> must provide methods to convert 
  23.  * the represented numeric value to <code>byte</code>, <code>double</code>,
  24.  * <code>float</code>, <code>int</code>, <code>long</code>, and
  25.  * <code>short</code>.
  26.  *
  27.  * @author    Lee Boynton
  28.  * @author    Arthur van Hoff
  29.  * @version 1.21, 07/01/98
  30.  * @see     java.lang.Byte
  31.  * @see     java.lang.Double
  32.  * @see     java.lang.Float
  33.  * @see     java.lang.Integer
  34.  * @see     java.lang.Long
  35.  * @see     java.lang.Short
  36.  * @since   JDK1.0
  37.  */
  38. public abstract class Number implements java.io.Serializable {
  39.     /**
  40.      * Returns the value of the specified number as an <code>int</code>.
  41.      * This may involve rounding.
  42.      *
  43.      * @return  the numeric value represented by this object after conversion
  44.      *          to type <code>int</code>.
  45.      * @since   JDK1.0
  46.      */
  47.     public abstract int intValue();
  48.  
  49.     /**
  50.      * Returns the value of the specified number as a <code>long</code>.
  51.      * This may involve rounding.
  52.      *
  53.      * @return  the numeric value represented by this object after conversion
  54.      *          to type <code>long</code>.
  55.      * @since   JDK1.0
  56.      */
  57.     public abstract long longValue();
  58.  
  59.     /**
  60.      * Returns the value of the specified number as a <code>float</code>.
  61.      * This may involve rounding.
  62.      *
  63.      * @return  the numeric value represented by this object after conversion
  64.      *          to type <code>float</code>.
  65.      * @since   JDK1.0
  66.      */
  67.     public abstract float floatValue();
  68.  
  69.     /**
  70.      * Returns the value of the specified number as a <code>double</code>.
  71.      * This may involve rounding.
  72.      *
  73.      * @return  the numeric value represented by this object after conversion
  74.      *          to type <code>double</code>.
  75.      * @since   JDK1.0
  76.      */
  77.     public abstract double doubleValue();
  78.  
  79.     /**
  80.      * Returns the value of the specified number as a <code>byte</code>.
  81.      * This may involve rounding or truncation.
  82.      *
  83.      * @return  the numeric value represented by this object after conversion
  84.      *          to type <code>byte</code>.
  85.      * @since   JDK1.1
  86.      */
  87.     public byte byteValue() {
  88.     return (byte)intValue();
  89.     }
  90.  
  91.     /**
  92.      * Returns the value of the specified number as a <code>short</code>.
  93.      * This may involve rounding or truncation.
  94.      *
  95.      * @return  the numeric value represented by this object after conversion
  96.      *          to type <code>short</code>.
  97.      * @since   JDK1.1
  98.      */
  99.     public short shortValue() {
  100.     return (short)intValue();
  101.     }
  102.  
  103.     /** use serialVersionUID from JDK 1.0.2 for interoperability */
  104.     private static final long serialVersionUID = -8742448824652078965L;
  105. }
  106.